########################################
# Blocks
########################################
snippet if "" b
if ($1) {
  ${0:${VISUAL}}
}
endsnippet

snippet ife "" b
if ($1) {
  ${2:${VISUAL}}
} else {
  $0
}
endsnippet

snippet try "" b
try {
  ${1:${VISUAL}}
} catch (err) {
  $0
}
endsnippet
########################################


########################################
# Functions/Classes
########################################
snippet fn "" w
function ${1:myFn}($2) {
  $0
}
endsnippet

snippet class "" b
class ${1:myClass} {
  $0
}
endsnippet
########################################


########################################
# Logs
########################################
snippet "log|warn|error|info|table" "" wr
console.`!p snip.rv = match.group(0)`($0)
endsnippet

snippet group "" b
console.groupCollapsed($1)
${0:${VISUAL}}
console.groupEnd()
endsnippet

snippet time "" b
console.time($1)
${0:${VISUAL}}
console.timeEnd($1)
endsnippet
########################################

########################################
# Import/Require
########################################
snippet import "" b
import ${2:{ $0 }} from '$1'
endsnippet

snippet require "" b
${2:const ${3:{ $0 } }= }require('${1:lib}')
endsnippet

########################################
# React
########################################
snippet r:c "Define a React stateful component" b
import React from 'react'
import PropTypes from 'prop-types'

class ${1:Comp} extends React.Component {
  render() {
    $0
  }
}

$1.propTypes = {}

export default $1
endsnippet

snippet r:fc "Define a React functional component" b
import React from 'react'
import PropTypes from 'prop-types'

const ${1:Comp} = props => ${2:(
  <div>$1</div>
)}

$1.propTypes = {}

export default $1
endsnippet

snippet r:cc "Define a connected React component" b
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'

class ${1:Comp} extends React.Component {
  render() {
    $0
  }
}

$1.propTypes = {}

function mapDispatchToProps() {}

function mapStateToProps() {}

export default connect(mapStateToProps, mapDispatchToProps)($1)
endsnippet
########################################


########################################
# Angular
########################################
snippet ng:c "Define an Angular component" b
import { Component, Input } from '@angular/core'

@Component({
  selector: '',
  styleUrls: ['./$2.component.scss'],
  templateUrl: './$2.component.html'
})
export class $1Component {}
endsnippet

snippet ng:m "Define an Angular module" b
import { NgModule } from '@angular/core'

@NgModule({
  declarations: [],
  imports: [],
  exports: [],
  providers: []
})
export class $1Module {}
endsnippet

snippet ng:s "Define an Angular service" b
import { Injectable } from '@angular/core'

@Injectable()
export class $1Service {}
endsnippet
########################################

########################################
# Testing
########################################
snippet "describe|context" "Define a test suit" br
`!p snip.rv = match.group(0)`('${1:this}', () => {
  $0
})
endsnippet

snippet it "Define a spec" b
it('${1:works}', () => {
  $0
})
endsnippet
